package jasepro;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class URLTunnelReader {

    private final static String proxyHost = "ChauDinh";
    private final static String proxyPort = "8080";

    public static void main(String[] args) throws Exception {
        System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
        System.setProperty("https.proxyHost", "ChauDinh");
        System.setProperty("https.proxyPort", "8080");

        URL verisign = new URL("https://www.verisign.com");
        URLConnection urlc = verisign.openConnection(); // from secure site
        if (urlc instanceof com.sun.net.ssl.HttpsURLConnection) {
            ((com.sun.net.ssl.HttpsURLConnection) urlc).setSSLSocketFactory(new SSLTunnelSocketFactory(proxyHost,
                    proxyPort));
        }

        BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

        String inputLine;

        while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine);

        in.close();
    }
}
